package com.gzs.learn.springcloud.service.impl;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service;
import com.gzs.learn.springcloud.dto.DateEntityDto;
import com.gzs.learn.springcloud.service.ISayHelloService;

@Service
public class SayHelloServiceImpl implements ISayHelloService{

    @Override
    public DateEntityDto getDateEntity() {
        Date now  = new Date();
        LocalDate localDate = LocalDate.now();
        DateEntityDto dateEntityDto = DateEntityDto.builder()
            .dateForJackson(DateUtils.addDays(now, 1))
            .defaultDate(now)
            .dateTimeForJackson(DateUtils.addDays(now, -1))
            .localDate(localDate)
            .localDateForJackson(localDate.plusDays(1))
            .localDateTimeForJackson(LocalDateTime.now().plusDays(-1))
            .build();
        return dateEntityDto;
    }

}
